<?php
$fp = fopen('t.txt', 'w+');
echo 'open flie success';
if (flock($fp, LOCK_EX))
{
    echo 'file locking';
    sleep(10);
    fwrite($fp, time());
    flock($fp, LOCK_UN);
}
else
{
    echo 'can not lock the file';
}
fclose($fp);
